package com.maltys.greedy;

/**
 * @author malty
 * @link <a href="https://leetcode.cn/problems/wiggle-subsequence/description/">...</a>
 */
public class WiggleSubsequence {
    public int wiggleMaxLength(int[] nums) {
        if (nums.length < 2) {
            return nums.length;
        }
        int prediff = 0;
        int cnt = 1;
        for (int i = 1; i < nums.length; i++) {
            int curDiff = nums[i] - nums[i - 1];
            if (curDiff == 0) {
                continue;
            }
            if (curDiff * prediff <= 0) {
                cnt++;
                prediff = curDiff;
            }
        }
        return cnt;
    }

    public static void main(String[] args) {
        WiggleSubsequence subsequence = new WiggleSubsequence();
        int maxLength = subsequence.wiggleMaxLength(new int[]{0,0});
        System.out.println(maxLength);
    }
}
